<?php if (!defined('ITPK')) exit('You can not directly access the file.');

/**
 * 运行记录操作类
 * @author 冬天的秘密
 * @link http://bbs.itpk.cn
 * @version 1.0
 */

class WebrunlogPer extends WebDBConnection {

	/**
	 * 获取最新的运行记录
	 * @param string $uin
	 * @param int $limit
	 * @return Ambigous <array, boolean>
	 */
	public function getMe($uin, $limit) {
		return $this->db->executeQuery("SELECT * FROM web_run_log where uin = '{$uin}' or uin = 'system' ORDER BY id DESC LIMIT {$limit}", true, true);
	}

	/**
	 * 获取最后一次正常运行记录的时间戳
	 * @param string $uin
	 * @param string $msg
	 * @return int
	 */
	public function getLastTimeByMsg($uin, $msg = "正常运行中") {
		$log = $this->db->executeQuery("SELECT * FROM web_run_log where uin = '{$uin}' and msg = '{$msg}' ORDER BY id DESC LIMIT 1", true);
		return $log ? $log['createdate'] : 0;
	}

	/**
	 * 添加运行记录
	 * @param string $uin
	 * @param string $verification
	 */
	public function insertMe($uin, $status) {
		return  $this->db->executeQuery("INSERT INTO web_run_log(uin, msg, createdate) values ('{$uin}', '{$status}', " . time() . ")");
	}

} 
?>